#ifndef NCMANAGER_H_
#define NCMANAGER_H_

#include <map>
#include <site>
#include "Domain.h"
#include <queue>
#include <pthread.h>


//Gamb
/*bool compareURL(std::string left, std::string right);

struct URLComparison {
   bool operator () (std::string  left, std::string right)
      { 
	   		return compareURL(left,right);
      }
}; */
 
class NCManager
{
public:
	NCManager();
	virtual ~NCManager();
	bool hasDomain(std::string domainStr);
	void addDomain(Domain* domain);
	Domain* getDomain(std::string domainStr);
	void addToVisitQueue(std::string url);
	std::string popUrlToVisit();
	std::queue<std::string>* getVisitQueue1();
	std::queue<std::string>* getVisitQueue2();
	std::queue<std::string>* getVisitQueue3();
	std::queue<std::string>* getVisitQueue4();
	void addToDownloadedSet(std::string site);
	bool isDownloaded(std::string urlSite);
	void init();
	pthread_mutex_t queueMutex;
	pthread_mutex_t domainsMutex;
	pthread_mutex_t pageCounterMutex;
	pthread_mutex_t robotsCounterMutex;
	pthread_mutex_t donwloadedSitesMutex;
	static int visitedSites;
	static int fetchedRobots;
	friend bool compareURL(std::string left, std::string right);
	static NCManager* mainShip;
	std::map <std::string, Domain*> domains;
	std::set<std::string> downloadedSites;
	void addToDownloadSetMD5(std::string site);

private:
	
	//std::priority_queue < std::string, std::vector<std::string>, URLComparison> visitQueue;
	std::queue<std::string> P1Queue;
	std::queue<std::string> P2Queue;
	std::queue<std::string> P3Queue;
	std::queue<std::string> P4Queue;
	
	


};



#endif /*NCMANAGER_H_*/
